SET(MODULE_NAME tsin-util)

IF(WIN32)
INCLUDE_DIRECTORIES("${PROJECT_SOURCE_DIR}/thirdparty/SDL/include"
                   )
LINK_DIRECTORIES("${PROJECT_SOURCE_DIR}/thirdparty/SDL/lib"
                )
ENDIF()

SET(CONTAINER_FILES ${PROJECT_SOURCE_DIR}/include/tsin/util/ArraySet.hpp
                    ${PROJECT_SOURCE_DIR}/include/tsin/util/Set.hpp
   )
SET(LOGGER_FILES ${PROJECT_SOURCE_DIR}/include/tsin/util/ConsoleLogger.hpp
                 ${PROJECT_SOURCE_DIR}/include/tsin/util/FileLogger.hpp
                 ${PROJECT_SOURCE_DIR}/include/tsin/util/Logger.hpp
                 ${PROJECT_SOURCE_DIR}/src/tsin/util/ConsoleLogger.cpp
                 ${PROJECT_SOURCE_DIR}/src/tsin/util/FileLogger.cpp
                 ${PROJECT_SOURCE_DIR}/src/tsin/util/Logger.cpp
   )
SET(TIMER_FILES ${PROJECT_SOURCE_DIR}/include/tsin/util/Timer.hpp
                ${PROJECT_SOURCE_DIR}/include/tsin/util/GFXTimer.hpp
                ${PROJECT_SOURCE_DIR}/src/tsin/util/GFXTimer.cpp
   )
SET(EVENT_FILES ${PROJECT_SOURCE_DIR}/include/tsin/util/EventListener.hpp
                ${PROJECT_SOURCE_DIR}/include/tsin/util/EventMediator.hpp
                ${PROJECT_SOURCE_DIR}/include/tsin/util/EventSource.hpp
                ${PROJECT_SOURCE_DIR}/src/tsin/util/EventMediator.cpp
                ${PROJECT_SOURCE_DIR}/src/tsin/util/EventSource.cpp
   )
SET(MISC_FILES ${PROJECT_SOURCE_DIR}/include/tsin/util/common.hpp
               ${PROJECT_SOURCE_DIR}/include/tsin/util/RefCnt.hpp
               ${PROJECT_SOURCE_DIR}/include/tsin/util/Resolution.hpp
               ${PROJECT_SOURCE_DIR}/src/tsin/util/RefCnt.cpp
               ${PROJECT_SOURCE_DIR}/src/tsin/util/Resolution.cpp
   )
SOURCE_GROUP("Bullet Set" FILES ${BULLETSET_FILES})
SOURCE_GROUP("Logger" FILES ${LOGGER_FILES})
SOURCE_GROUP("Timer" FILES ${TIMER_FILES})
SOURCE_GROUP("misc" FILES ${MISC_FILES})
SET(FILES ${CONTAINER_FILES} ${LOGGER_FILES} ${TIMER_FILES} ${EVENT_FILES} ${MISC_FILES})

IF(TSIN_ENABLE_MEM_CHECK)
SET(MEMCHECK_FILES ${PROJECT_SOURCE_DIR}/include/tsin/util/MemCheck.hpp
                   ${PROJECT_SOURCE_DIR}/src/tsin/util/MemCheck.cpp
                   ${PROJECT_SOURCE_DIR}/src/tsin/MemCheckStub.cpp)
SET(FILES ${FILES}
          ${MEMCHECK_FILES})
SOURCE_GROUP("Memory Check" FILES ${MEMCHECK_FILES})
ADD_DEFINITIONS(-DTSIN_MEMCHECK)
ENDIF()

SET(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR})

ADD_LIBRARY(${MODULE_NAME} SHARED ${FILES} ${HEADERS})
SET_TARGET_PROPERTIES(${MODULE_NAME} PROPERTIES COMPILE_DEFINITIONS "UTIL_DEFINITION")
SET_TARGET_PROPERTIES(${MODULE_NAME} PROPERTIES LINK_INTERFACE_LIBRARIES "")
SET_TARGET_PROPERTIES(${MODULE_NAME} PROPERTIES PREFIX "")
SET_TARGET_PROPERTIES(${MODULE_NAME} PROPERTIES SUFFIX ".so")
SET_TARGET_PROPERTIES(${MODULE_NAME} PROPERTIES OUTPUT_NAME ${MODULE_NAME})
TARGET_LINK_LIBRARIES(${MODULE_NAME} SDL SDL_gfx)
INSTALL(TARGETS tsin-util DESTINATION .)
